<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>AdminLTE 3 | Data Tables</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body class="hold-transition sidebar-mini">
<div class="wrapper">
    <!-- Main content -->
    <section class="content">
        <div class="row">
            <div class="col-12">
                <div class="card">
                    <div class="card-header">
                        <button id="add" class="btn btn-primary btn-sm">添加用户</button>
                        <button id="import" class="btn btn-primary btn-sm">批量导入</button>
                    </div>
                    <!-- /.card-header -->
                    <div class="card-body">
                        <table id="example2" class="table table-bordered table-hover">
                        </table>
                    </div>
                    <!-- /.card-body -->
                </div>
            </div>
            <!-- /.col -->
        </div>
        <!-- /.row -->
    </section>
    <!-- /.content -->
    <footer class="main-footer text-center" style="margin-left: 0%;">
        <div class="d-none d-sm-block">
            <b>版本:</b> 1.0
        </div>
        <!-- 按钮触发模态框 -->
        <strong>Copyright &copy; 2014-2018 <a href="http://adminlte.io">咸阳恒源汽贸有限公司</a>.</strong>保留所有权.
    </footer>

    <!-- Control Sidebar -->
    <aside class="control-sidebar control-sidebar-dark">
        <!-- Control sidebar content goes here -->
    </aside>
    <!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->


<!-- 模态框（Modal） -->
<div class="modal fade" id="myModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="max-width: 1000px;">
        <div class="modal-content">
            <div class="modal-header">

                <h4 class="modal-title" id="myModalLabel">管理员账号管理</h4>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body">
                <!-- form start -->
                <form role="form" action="" id="form_submit">
                    <div class="row">
                        <div class="col-lg-2 mt-2">
                            <div class="">
                                <div style=" line-height: 1.5em;margin-top: 6px;" class="text-center"><code>*</code>&nbsp;&nbsp;员工编号
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9 mt-2">
                            <div class="form-group">
                                <input name="code" type="text" class="form-control" id="u_id" placeholder=""
                                       disabled>
                                <input name="aid" type="text" class="form-control" id="u_fid" placeholder=""
                                       style="display: none">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2 mt-2">
                            <div class="">
                                <div style=" line-height: 1.5em;margin-top: 6px;" class="text-center"><code>*</code>&nbsp;&nbsp;员工姓名
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9 mt-2">
                            <div class="form-group">
                                <input name="name" type="text" class="form-control" id="u_name" value="">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2">
                            <div class="">
                                <div style="line-height: 1.5em;margin-top: 6px;" class="text-center"><code>*</code>&nbsp;&nbsp;员工头像
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9">
                            <div class="form-group">
                                <input name="img" type="text" class="form-control" id="p_image" value="">
                            </div>
                            <div>
                                <img id="pimg" style="width: 200px">
                            </div>
                            <div id="easyContainer" style="width: 100%"></div>

                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2">
                            <div class="">
                                <div style=" line-height: 1.5em;margin-top: 6px;" class="text-center"><code>*</code>&nbsp;&nbsp;身份证号码
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9">
                            <div class="form-group">
                                <input name="identityCard" type="text" class="form-control" id="identityCard" value="">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2">
                            <div class="">
                                <div style=" line-height: 1.5em;margin-top: 6px;" class="text-center"><code>*</code>&nbsp;&nbsp;联系电话
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9">
                            <div class="form-group">
                                <input name="tel" type="text" class="form-control" id="u_tel" value="18766881688">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2">
                            <div class="">
                                <div style=" line-height: 1.5em;margin-top: 6px;" class="text-center"><code>*</code>&nbsp;&nbsp;出生日期
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9">
                            <div class="form-group">
                                <input name="birth" type="text" class="form-control" id="u_birth" value="1976-2-15">
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2">
                            <div class="">
                                <div style=" line-height: 1.5em;margin-top: 6px;" class="text-center"><code>*</code>&nbsp;&nbsp;性别
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9">
                            <!-- /.form-group -->
                            <div class="form-group">
                                <select id="sex" name="sex" class="form-control select2" style="width: 100%;">
                                    <option value="1">男</option>
                                    <option value="0">女</option>
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2">
                            <div class="">
                                <div style=" line-height: 1.5em;margin-top: 6px;" class="text-center"><code>*</code>&nbsp;&nbsp;职位
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9">
                            <!-- /.form-group -->
                            <div class="form-group">
                                <select id="comId" name="comId" class="form-control select2 float-left"
                                        style="width: 24%;">
                                </select>
                                <select id="subComId" name="subComId" class="form-control select2 float-left"
                                        style="width: 24%;">
                                </select>
                                <select id="depId" name="depId" class="form-control select2 float-left"
                                        style="width: 24%;">
                                </select>
                                <select id="posId" name="posId" class="form-control select2" style="width: 24%;">
                                </select>
                            </div>
                        </div>
                    </div>
                    <div class="row">
                        <div class="col-lg-2">
                            <div class="">
                                <div style=" line-height: 1.5em;margin-top: 6px;" class="text-center"><code>*</code>&nbsp;&nbsp;在职状态
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9">
                            <!-- /.form-group -->
                            <div class="form-group">
                                <select id="isjob" name="isjob" class="form-control select2" style="width: 100%;">
                                    <option value="1">在职</option>
                                    <option value="0">离职</option>
                                </select>
                            </div>
                        </div>
                    </div>


                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button id="save" type="button" class="btn btn-primary">保存</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!-- 模态框（Modal） -->
<div class="modal fade" id="uploadModal" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="max-width: 1000px;height: 400px">
        <div class="modal-content">
            <div class="modal-header">

                <h4 class="modal-title" id="myModalLabel">批量导入</h4>
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            </div>
            <div class="modal-body">
                <!-- form start -->
                <form role="form" action="">

                    <div class="row">
                        <div class="col-lg-2">
                            <div class="">
                                <div style="line-height: 1.5em;margin-top: 6px;" class="text-center"><code>*</code>&nbsp;&nbsp;上传文件
                                </div>
                            </div>
                        </div>
                        <div class="col-lg-9">
                            <div class="form-group">
                                <input name="fileName" type="text" class="form-control" id="fileName" value="">
                            </div>
                            <div id="msg-content">

                            </div>
                            <div id="uploadContainer" style="width: 100%"></div>

                        </div>
                    </div>


                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button id="importBtn" type="button" class="btn btn-primary">开始导入</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>
<!--点击删除按钮后弹出的页面-->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog" style="height: 200px">
        <div class="modal-content">
            <div class="modal-header">
                <h4 class="modal-title" id="myModalLabel">
                    提示
                </h4>
                <!--<button type="button" class="close" data-dismiss="modal" aria-hidden="true">-->
                <!--&times;-->
                <!--</button> -->
            </div>
            <div class="modal-body">
                你确定要删除该条信息吗？
                <input id="del_id" style="display: none"/>
            </div>
            <div class="modal-footer">
                <button id="delBtn" type="submit" class="btn btn-primary" value="submit">确定</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div><!-- /.modal-content -->
    </div><!-- /.modal -->
</div>

<!-- page script -->
<script>
    $(function () {
        $("#myModal").on("hidden.bs.modal", function () {
            $('#myModal').removeData("bs.modal");
        });


        var user_table = $('#example2').DataTable({
            "language": {
                "url": "./plugins/datatables/chinese.txt"
            },
            "serverSide": true,
            "paging": true,
            "lengthChange": true,
            "searching": true,
            "ordering": true,
            "info": true,
            "autoWidth": false,
            "ajax": {
                "url": './adminUserList.action?type=1',
                "type": 'POST'
            },
            columns: [
                {
                    "data": null,
                    "title": "序号",
                    "sClass": "text-tables-center text-center",
                    "createdCell": function (nTd, sData, oData, iRow, iCol) {
                        var startnum = this.api().page() * (this.api().page.info().length);
                        $(nTd).html(iRow + 1 + startnum); //分页行号累加：$(nTd).html(iRow+1);
                    }
                },
                {data: 'loginname', 'title': '账号', 'sClass': "text-center"},
                {data: 'name', 'title': '名称', 'sClass': "text-center"},
                {data: 'uname', 'title': '管理员', 'sClass': "text-center"},
                {data: 'tel', 'title': '手机', 'sClass': "text-center"},
                {data: 'roleType.name', 'title': '角色类型', 'sClass': "text-center"},
                {data: 'createTime', 'title': '创建时间', 'sClass': "text-center"},
                {data: 'lastTime', 'title': '最后登录时间', 'sClass': "text-center"},
                {data: 'ip', 'title': '最后登录ip', 'sClass': "text-center"},
/*                {
                    data: 'isjob', 'title': '操作', 'sClass': "text-center",
                    render: function (data, type, row) {
                        var id = row.aid == undefined ? -1 : row.aid;//-1说明是新增，其余表示为编辑
                        return "<i class='fa fa-pencil l-fa edit-btn' style='cursor: pointer' id=\'" + id + "\'></i>&nbsp;&nbsp;<i class='fa fa-trash-o m-fa del-btn' style='cursor: pointer' id=\'" + id + "\'></i>";
                    }
                }*/
            ]
        });

        function userSearchBtn() {
            user_table.ajax.reload();   // 这边的user_table，是由初始化datatables的变量名
        }

        $("#importBtn").on("click", function SaveData() {
            $("#msg-content").empty();
            var name = $("#fileName").val();
            $("#importBtn").text("导入中...");
            if (name != null && name != "") {
                var url = "./batchImportData.action?type=1";
                $.ajax({
                    type: 'POST',
                    url: url,
                    data: {
                        "name": name
                    },
                    dataType: "json",
                    success: function (result) {
                        if (result.status == 200) {
                            userSearchBtn();
                            $("#msg-content").empty();
                            var text = "<label>数据导入成功!共计导入:<label style='color: red;font-size:18px'> " + result.total + "</label></font>条数据,成功:<label style='color: red;font-size:18px'>" + result.totalSuccess + "</label>条</label>"
                            $("#msg-content").append(text);
                            $("#importBtn").attr("disabled", "disabled");
                            $("#importBtn").text("导入完成");
                        } else {
                            $("#msg-content").empty();
                            var text = "<label style='color: red;font-size:18px'>" + result.message + "</label>"
                            $("#msg-content").append(text);
                            $("#importBtn").attr("disabled", "disabled");
                            $("#importBtn").text("导入失败");
                        }


                    },
                    dataType: "json"
                });
            } else {
                $("#msg-content").empty();
                var text = "<label style='color: red;font-size:18px'>请先上传批量导入文件</label>"
                $("#msg-content").append(text);
                $("#importBtn").text("开始导入");
            }

        });

        //点击编辑图标出现编辑框
        $("#example2 tbody").unbind('click').on("click", ".edit-btn", function () {
            var id = $(this).attr("id");
            if (id != -1) {
                var url = encodeURI("./getUserDetail.action");
                $.ajax({
                    type: 'POST',
                    url: url,
                    data: {
                        "contentId": id
                    },
                    dataType: "json",
                    success: function (result) {
                        if (result.success) {
                            //刷新表格
                            var data = result.data;
                            $("#u_id").val("FU00" + data.aid);
                            $("#u_fid").val(data.aid);
                            $("#u_name").val(data.name);
                            $("#p_image").val(data.img);
                            $("#identityCard").val(data.identityCard);
                            $("#pimg").attr("src", data.img);
                            if (data.position != null) {
                                $("#u_position").val(data.position.pname);
                            }


                            $("#u_tel").val(data.tel);
                            $("#u_birth").val(data.birth);

                            var options = $("#isjob").children();
                            $.each(options, function (i, val) {
                                var jqob = $(val);
                                //把input变为字符串
                                if (jqob.val() == data.isjob) {
                                    $("#isjob").val(jqob.val()).trigger("change");
                                    jqob.attr("selected", "selected");
                                }
                            });

                            var options = $("#sex").children();
                            $.each(options, function (i, val) {
                                var jqob = $(val);
                                //把input变为字符串
                                if (jqob.val() == data.sex) {
                                    $("#sex").val(jqob.val()).trigger("change");
                                    jqob.attr("selected", "selected");
                                }
                            });
                            uploadImg();
                            $('#myModal').modal('show');
                        } else {

                        }
                    },
                    dataType: "json"
                });
            } else {
                $('#myModal').modal('show');
            }

        });

        //删除
        $("#example2 tbody").on("click", ".del-btn", function () {
            var id = $(this).attr("id");
            $("#del_id").val(id);

            $('#deleteModal').modal('show');
            $("#deleteModal").bind('hide.bs.modal', function () {
                $(".modal-backdrop").remove();
            });

            $("#deleteModal").on('hidden.bs.modal', '.modal', function () {
                $(this).removeData('bs.modal');
            });


        });


        //保存按钮
        $("#example2 tbody").on("click", ".save-btn", function () {
            var id = $(this).attr("id");
            var tds = $(this).parents("tr").children();
            var sTds = tds.length;
            var lisval = [];
            for (var i = 0; i < sTds; i++) {
                if (i < sTds - 1)
                    lisval.push(tds.eq(i).children("input").val());
                else lisval.push(tds.eq(i).children("input").val())
            }
            if (i == sTds - 1) lisval.push();
            if (lisval[1] == "") {
                toNotification("警告！", "证照属性设置不能为空！", "warning");
                return false;
            } else if (lisval[1].length > 10) {
                toNotification("警告！", "证照属性设置不能超过十个字符！", "warning");
                return false;
            } else {
                $.each(tds, function (i, val) {
                    var jqob = $(val);
                    //把input变为字符串
                    if (!jqob.has('i').length) {
                        var txt = jqob.children("input").val();
                        jqob.html(txt);
                    }
                });
                $(this).toggleClass("edit-btn fa-pencil");
                $(this).toggleClass("save-btn fa-save");
                //保存数据
                SaveData(lisval, id);
            }

        });

        $('#form_submit').bootstrapValidator({

            message: 'This value is not valid',
            feedbackIcons: {
                valid: 'fa  fa-check',
                invalid: 'fa fa-times',
                validating: 'fa fa-refresh'
            },

            fields: {
                name: {
                    message: '用户名验证失败',
                    validators: {
                        notEmpty: {
                            message: '用户名不能为空'
                        }
                    }
                },
                identityCard: {
                    validators: {
                        notEmpty: {
                            message: '身份证号码不能为空'
                        }
                    }
                },
                tel: {
                    validators: {
                        notEmpty: {
                            message: '手机号码不能为空'
                        }
                    }
                }
            }

        });


        //证照属性设置保存信息
        $("#save").on("click", function SaveData() {
            $("#form_submit").bootstrapValidator('validate');//提交验证
            if ($("#form_submit").data('bootstrapValidator').isValid()) {//获取验证结果，如果成功，执行下面代码
                var data = $('#form_submit').serialize();
                //序列化获得表单数据，结果为：user_id=12&user_name=John&user_age=20
                var submitData = decodeURIComponent(data, true);
                //submitData是解码后的表单数据，结果同上
                var url = encodeURI("./saveUserAccount.action");
                $.ajax({
                    type: 'POST',
                    url: url,
                    data: data,
                    dataType: "json",
                    success: function (result) {
                        if (result.success) {
                            //刷新表格
                            $("#myModal").modal('hide');  //手动关闭
                            userSearchBtn();
                        } else {
                            //刷新表格
                            $("#myModal").modal('hide');  //手动关闭
                            userSearchBtn();
                        }

                        $("#myModal").bind('hide.bs.modal', function () {
                            $(".modal-backdrop").remove();
                        });
                    },
                    dataType: "json"
                });
            }
        });

        //证照属性设置新添加信息
        $("#add").on("click", function SaveData() {
            $("#u_id").val("");
            $("#u_fid").val("");
            $("#u_name").val("");
            $("#u_position").val("");
            $("#u_school").val("");
            $("#u_tel").val("");
            $("#identityCard").val("");
            $("#u_email").val("");
            $("#u_birth").val("");
            uploadImg();
            $('#myModal').modal('show');
        });

        //证照属性设置新添加信息
        $("#import").on("click", function SaveData() {
            importFile();
            $("#importBtn").text("开始导入");
            $("#fileName").val("");
            $("#msg-content").empty();
            $("#importBtn").removeAttr("disabled");
            $('#uploadModal').modal('show');
        });


        //证照属性设置删除
        $("#delBtn").on("click", function () {
            var id = $("#del_id").val();
            var data = {"contentId": id};
            var url = "./deleteUserAccount.action";
            //执行删除
            $.ajax({
                type: 'POST',
                url: url,
                data: data,
                dataType: "json",
                success: function (result) {
                    if (result.success) {

                        userSearchBtn();
                    } else {
                        userSearchBtn();
                    }
                    $('#deleteModal').modal('hide');
                },
                dataType: "json"
            });

        });

        //获得标识
        function getActionId() {
            return new Date().getTime();
        }

        $("#sex").select2();
        $("#isjob").select2();
        $("#subComId").select2();
        $("#depId").select2();
        $("#posId").select2();
        $("#comId").select2({
            ajax: {
                type: 'GET',
                url: "./ComPanyList.action?contentId=0&type=1",
                dataType: 'json',
                delay: 250,
                data: function (params) {
                    return {
                        search: params.term, // search term 请求参数 ， 请求框中输入的参数
                        page: params.page,
                        length: 10,// 每页显示多少行
                        type: 3
                    };
                },
                processResults: function (data, params) {
                    params.page = params.page || 1;
                    var itemList = [];//当数据对象不是{id:0,text:'ANTS'}这种形式的时候，可以使用类似此方法创建新的数组对象
                    var arr = data.data;
                    for (item in arr) {
                        itemList.push({id: arr[item].cid, text: arr[item].cname})
                    }
                    return {
                        results: itemList,//itemList
                        pagination: {
                            more: (params.page * 30) < data.recordsTotal
                        }
                    };
                },
                cache: false
            },
            placeholder: '请选择',//默认文字提示
            language: "zh-CN",
            delay: 250,// 延迟显示
            tags: true,//允许手动添加
            allowClear: true,//允许清空
            escapeMarkup: function (markup) {
                return markup;
            }, // 自定义格式化防止xss注入
            minimumInputLength: 1,//最少输入多少个字符后开始查询
            formatResult: function formatRepo(repo) {
                return repo.text;
            }, // 函数用来渲染结果
            formatSelection: function formatRepoSelection(repo) {
                return repo.text;
            } // 函数用于呈现当前的选择
        });
        $("#comId").on("change", function () {
            var id = $(this).val();
            if (id != null) {
                var url = "./ComPanyList.action?contentId=" + id + "&type=2";
                $.ajax({
                    type: 'POST',
                    url: url,
                    dataType: "json",
                    success: function (result) {
                        if (result.status = 200) {
                            //刷新表格
                            var data = result.data;

                            var gis_select = $("#subComId");
                            gis_select.empty();
                            $.each(data, function (i, val) {
                                gis_select.append("<option value='" + val.sid + "'>" + val.sname + "</option>");
                            });
                            gis_select.trigger("change");
                        }

                    },
                    dataType: "json"
                });
            } else {
                $("#subComId").empty();
                $("#subComId").trigger("change");
                $("#depId").empty();
                $("#depId").trigger("change");
                $("#posId").empty();
                $("#posId").trigger("change");
            }

        });
        $("#subComId").on("change", function () {
            var id = $(this).val();
            if (id != null) {
                var url = "./ComPanyList.action?contentId=" + id + "&type=3";
                $.ajax({
                    type: 'POST',
                    url: url,
                    dataType: "json",
                    success: function (result) {
                        if (result.status = 200) {
                            //刷新表格
                            var data = result.data;

                            var gis_select = $("#depId");
                            gis_select.empty();
                            $.each(data, function (i, val) {
                                gis_select.append("<option value='" + val.did + "'>" + val.dname + "</option>");
                            });
                            gis_select.trigger("change");
                        }

                    },
                    dataType: "json"
                });
            } else {
                $("#depId").empty();
                $("#depId").trigger("change");
                $("#posId").empty();
                $("#posId").trigger("change");
            }

        });
        $("#depId").on("change", function () {
            var id = $(this).val();
            if (id != null) {
                var url = "./ComPanyList.action?contentId=" + id + "&type=4";
                $.ajax({
                    type: 'POST',
                    url: url,
                    dataType: "json",
                    success: function (result) {
                        if (result.status = 200) {
                            //刷新表格
                            var data = result.data;

                            var gis_select = $("#posId");
                            gis_select.empty();
                            $.each(data, function (i, val) {
                                gis_select.append("<option value='" + val.pid + "'>" + val.pname + "</option>");
                            });
                            gis_select.trigger("change");
                        }

                    },
                    dataType: "json"
                });
            } else {
                var gis_select = $("#posId");
                gis_select.empty();
                gis_select.trigger("change");
            }

        });


        //Date range picker
        //定义locale汉化插件
        var locale = {
            "format": 'YYYY-MM-DD',
            "separator": " -222 ",
            "applyLabel": "确定",
            "cancelLabel": "取消",
            "fromLabel": "起始时间",
            "toLabel": "结束时间'",
            "customRangeLabel": "自定义",
            "weekLabel": "W",
            "daysOfWeek": ["日", "一", "二", "三", "四", "五", "六"],
            "monthNames": ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"],
            "firstDay": 1
        };
        $('#u_birth').daterangepicker({
            'locale': locale,
            startDate: moment().subtract(0, 'days'),
            singleDatePicker: true,
            format: 'YYYY-MM-DD'
        });
        $('#u_birth').val(moment().subtract('0', 'days').format('YYYY-MM-DD'));


    })
    ;

    function uploadImg() {
        $('#easyContainer').easyUpload({
            allowFileTypes: '*.png;*.jpg;',//允许上传文件类型，格式'*.jpg;*.doc;*.pdf'
            allowFileSize: 100000,//允许上传文件大小(KB)
            selectText: '选择文件',//选择文件按钮文案
            multi: false,//是否允许多文件上传
            multiNum: 1,//多文件上传时允许的文件数
            showNote: true,//是否展示文件上传说明
            note: '提示：最多上传1个文件，支持格式为doc、pdf、jpg',//文件上传说明
            showPreview: true,//是否显示文件预览
            url: './fileUpload.action',//上传文件地址
            fileName: 'file',//文件filename配置参数
            formParam: {
                /*token: $.cookie('token_cookie')//不需要验证token时可以去掉*/
            },//文件filename以外的配置参数，格式：{key1:value1,key2:value2}
            timeout: 10000,//请求超时时间
            okCode: 200,//与后端返回数据code值一致时执行成功回调，不配置默认200
            successFunc: function (res) {
                console.log('成功回调', res);
                if (res.fileName) {
                    $("#pimg").attr("src", res.fileName);
                    $("#p_image").val(res.fileName);
                }

            },//上传成功回调函数
            errorFunc: function (res) {
                console.log('失败回调', res);
            },//上传失败回调函数
            deleteFunc: function (res) {
                console.log('删除回调', res);
            }//删除文件回调函数
        });
    }

    function importFile() {
        $('#uploadContainer').easyUpload({
            allowFileTypes: '*.xlsx;*.xls;',//允许上传文件类型，格式'*.xlsx'
            allowFileSize: 100000,//允许上传文件大小(KB)
            selectText: '选择Excel文件',//选择文件按钮文案
            multi: false,//是否允许多文件上传
            multiNum: 1,//多文件上传时允许的文件数
            showNote: true,//是否展示文件上传说明
            note: '提示：最多上传1个文件，支持格式为xlsx.xls',//文件上传说明
            showPreview: true,//是否显示文件预览
            url: './excelfileUpload.action',//上传文件地址
            fileName: 'file',//文件filename配置参数
            formParam: {
                /*token: $.cookie('token_cookie')//不需要验证token时可以去掉*/
            },//文件filename以外的配置参数，格式：{key1:value1,key2:value2}
            timeout: 10000,//请求超时时间
            okCode: 200,//与后端返回数据code值一致时执行成功回调，不配置默认200
            successFunc: function (res) {
                console.log('成功回调', res);
                $("#msg-content").empty();
                $("#fileName").val(res.fileName);
                $("#importBtn").removeAttr("disabled");
                /*                if(res.fileName){
                 $("#pimg").attr("src",res.fileName);
                 $("#p_image").val(res.fileName);
                 }*/

            },//上传成功回调函数
            errorFunc: function (res) {
                console.log('失败回调', res);
            },//上传失败回调函数
            deleteFunc: function (res) {
                console.log('删除回调', res);
            }//删除文件回调函数
        });
    }

</script>
</body>
</html>
